home *** CD-ROM | disk | FTP | other *** search
/ Crosscountry USA Photo Safari / Crosscountry USA Photo Safari.iso / Data / safari_usa / pak00_16bit_f.pk3 / common / country_specific.c4 next >
Text File  |  2004-01-21  |  19KB  |  463 lines

  1.  
  2. {
  3.   @check_custom_order {
  4.   
  5.     resid Game;
  6.     resid Player;
  7.     resid Message;
  8.     str nav_cur_city;
  9.     int tmp_int;
  10.     int time_now;
  11.  
  12.     Game = ResByName("Game");   
  13.     Player = ResPropGetResID(Game,"game_cur_player");
  14.     Message = ResByName("dash.gl/message");
  15.     time_now = ResPropGetInt(Player,"time_now");
  16.  
  17.     ResPropAlias(Player, "nav_cur_city", "nav_cur_city");
  18.  
  19.     /*  see if the order from iqualuit is in */
  20.     if (
  21.          (StrExact(nav_cur_city,"San Francisco")) &&
  22.          (ResPropGetInt(Player, "nav_order_hawaii") == 1) &&
  23.          ( 
  24.            (time_now + ResPropGetInt(Player,"time_zone_real_offset")) < 
  25.            ResPropGetInt( Player, "nav_order_hawaii_time") 
  26.          )              
  27.        ) {
  28.       
  29.       tmp_int = ResPropGetInt( Player, "nav_order_hawaii_time") - time_now;
  30.       tmp_int  /= 3600;
  31.        
  32.       ResPropSetStr(Message, "InputText", StrFormatStr(MangleSIDToStr(65536/*"The shipment from Hawaii will arrive in %d hour(s)."*/),tmp_int+1));
  33.       ResPropSetInt(Message, "timeout", CVarGetInt("framerate") * 8);
  34.     }
  35.     
  36.     /*  see if the order from alaska is in */
  37.     if (
  38.          (StrExact(nav_cur_city,"Seattle")) &&
  39.          (ResPropGetInt(Player, "nav_order_alaska") == 1) &&
  40.          ( 
  41.            (time_now + ResPropGetInt(Player,"time_zone_real_offset")) < 
  42.            ResPropGetInt( Player, "nav_order_alaska_time") 
  43.          )              
  44.        ) {
  45.        
  46.       tmp_int = ResPropGetInt( Player, "nav_order_alaska_time") - time_now;
  47.       tmp_int  /= 3600;
  48.        
  49.       ResPropSetStr(Message, "InputText", StrFormatStr(MangleSIDToStr(65537/*"The tanker from Alaska will arrive in %d hour(s)."*/),tmp_int+1));
  50.       ResPropSetInt(Message, "timeout", CVarGetInt("framerate") * 8);
  51.     }
  52.   }
  53.  
  54.   @set_speed_label {
  55.     ResPropSetStr(ResByName("dash.gl/speed_label"),"InputText",MangleSIDToStr(65538/*"MPH"*/));
  56.   }
  57.   
  58.   @cell_phone_populate_options {
  59.         GuiListboxAppend(ResByName("cell_phone.gl/call_options"),MangleSIDToStr(65539/*"Tow Truck"*/));
  60.  
  61.   }
  62.   
  63.   @cell_phone_make_call {
  64.  
  65.     resid Player;
  66.     resid Game;
  67.     resid Scenario;
  68.     resid Message;
  69.     resid BonusCommodity;
  70.     resid CurCommodity;
  71.     
  72.     int found_pineapples;
  73.     int found_crude;          
  74.     int i;          
  75.     int num_commodities;
  76.     int time_pickup;
  77.     str call_option;
  78.     int time_zone_real_offset;
  79.     
  80.     
  81.     Game             = ResByName("Game");   
  82.     Message          = ResByName("dash.gl/message");
  83.     Player           = ResPropGetResID(Game,"game_cur_player");
  84.     Scenario         = ResPropGetResID(Player,"scenario_id");           
  85.     num_commodities  = ResPropGetInt(Scenario,"scenario_commodity_number_of");
  86.     call_option      = GuiListboxGetSelected(ResByName("cell_phone.gl/call_options"));
  87.     time_zone_real_offset = ResPropGetInt(Player,"time_zone_real_offset");
  88.     time_pickup = ResPropGetInt(Player,"time_now") + time_zone_real_offset;
  89.     time_pickup += 172800;
  90.     
  91.     /*  */
  92.     if (StrExact(call_option,"")) {
  93.       ResPropSetStr(Message, "InputText", MangleSIDToStr(65540/*"Select an option from the list."*/));
  94.       ResPropSetInt(Message, "timeout", CVarGetInt("framerate") * 6);
  95.       stop;
  96.     }
  97.     
  98.     
  99.     
  100.     
  101.     /* call tow truck */
  102.     if (StrExact(call_option,"Tow Truck")) {
  103.       if ((ResPropGetInt(Player,"truck_broken") == 1) ||
  104.           (ResPropGetInt(Player,"truck_tire_flat") == 1) ||
  105.           (ResPropGetInt(Player,"truck_fuel_remaining") <= 0)) {
  106.           /* set the segment state to tow truck */
  107.         if (ResPropGetInt(Player,"nav_at_city") == 1) {
  108.           ResPropSetStr(Message, "InputText", MangleSIDToStr(65541/*"You can't call a tow truck here."*/));
  109.           ResPropSetInt(Message, "timeout", CVarGetInt("framerate") * 6);
  110.         } else {
  111.           CVarSetInt("guiInputEnabled",0);
  112.           ResPropSetInt(ResByName("dash.gl/SegmentController"),"state",8);
  113.         }
  114.       } else {
  115.         ResPropSetStr(Message, "InputText", MangleSIDToStr(65542/*"There's no need to call a tow truck."*/));
  116.         ResPropSetInt(Message, "timeout", CVarGetInt("framerate") * 8);
  117.         stop;
  118.       }
  119.       ResPropSetInt(GuiParent(SELF),"Hidden",TRUE);
  120.       stop;
  121.     }
  122.     
  123.     /* call hawaii */
  124.     if (StrExact(call_option,"Hawaii")) {
  125.       if( ResPropGetInt(Player,"nav_order_hawaii") == 1 ) {
  126.         ResPropSetStr(Message, "InputText", MangleSIDToStr(65543/*"You have already placed an order for pineapples."*/));
  127.         ResPropSetInt(Message, "timeout", CVarGetInt("framerate") * 6);
  128.         stop;
  129.       }
  130.     
  131.       /*
  132.          make sure we dont order if we dont need to, we do this because they 
  133.          would be able to get pineapples even if they don't need to 
  134.       */
  135.     
  136.       i = 1;
  137.       found_pineapples = 0;
  138.       while (i <= num_commodities) {
  139.         CurCommodity   = ResPropGetResID(Player,StrFormatStr("commodity_%d",i));
  140.         BonusCommodity = ResPropGetResID(Player,"commodity_bonus");
  141.         if ( StrExact(ResPropGetStr(CurCommodity,"commodity_name"),"Pineapples") ) {
  142.           found_pineapples = 1;
  143.         }
  144.         if ( StrExact(ResPropGetStr(BonusCommodity,"commodity_name"),"Pineapples") ) {
  145.           found_pineapples = 1;
  146.         }              
  147.         i += 1;
  148.       }            
  149.       
  150.       /* tell them why we cant order them */
  151.       if (found_pineapples == 0) {
  152.         ResPropSetStr(Message, "InputText", MangleSIDToStr(65544/*"Pineapples are not needed to complete this assignment."*/));
  153.         ResPropSetInt(Message, "timeout", CVarGetInt("framerate") * 8);
  154.         stop;
  155.       }
  156.       
  157.       
  158.       AudioPlay(ResByName("sound/cell_phone.wav"));
  159.       ResPropSetStr(Message, "InputText", MangleSIDToStr(65545/*"Your order of pineapples from Hawaii will arrive in San Francisco in two days."*/));
  160.       ResPropSetInt(Message, "timeout", CVarGetInt("framerate") * 8);
  161.       ResPropSetInt(Player,"nav_order_hawaii",1);
  162.       ResPropSetInt(Player,"nav_order_hawaii_time", time_pickup);
  163.       ResPropSetInt(GuiParent(SELF),"Hidden",TRUE);
  164.       stop;
  165.     }
  166.     
  167.     /* call alaska */
  168.     if (StrExact(call_option,"Alaska")) {
  169.       
  170.       /* check if an order has already been set */
  171.       if( ResPropGetInt(Player,"nav_order_alaska") == 1 ) {
  172.         ResPropSetStr(Message, "InputText", MangleSIDToStr(65546/*"You have already placed an order for oil."*/));
  173.         ResPropSetInt(Message, "timeout", CVarGetInt("framerate") * 6);
  174.         stop;
  175.       }
  176.     
  177.       /*
  178.          make sure we dont order if we dont need to, we do this because they 
  179.          would be able to get pineapples even if they don't need to 
  180.       */
  181.       
  182.       i = 1;
  183.       found_crude = 0;
  184.       while (i <= num_commodities) {
  185.         CurCommodity   = ResPropGetResID(Player,StrFormatStr("commodity_%d",i));
  186.         BonusCommodity = ResPropGetResID(Player,"commodity_bonus");
  187.         if ( StrExact(ResPropGetStr(CurCommodity,"commodity_name"),"Oil") ) {
  188.           found_crude = 1;
  189.         }
  190.         if ( StrExact(ResPropGetStr(BonusCommodity,"commodity_name"),"Oil") ) {
  191.           found_crude = 1;
  192.         }
  193.         i += 1;
  194.       }            
  195.       
  196.       
  197.       /* tell them why we cant order them */
  198.       if (found_crude == 0) {
  199.         ResPropSetStr(Message, "InputText", MangleSIDToStr(65547/*"Oil is not needed to complete this assignment."*/));
  200.         ResPropSetInt(Message, "timeout", CVarGetInt("framerate") * 8);
  201.         stop;
  202.       }
  203.     
  204.       AudioPlay(ResByName("sound/cell_phone.wav"));
  205.       ResPropSetStr(Message, "InputText", MangleSIDToStr(65548/*"The oil tanker from Alaska will arrive in Seattle in two days."*/));
  206.       ResPropSetInt(Message, "timeout", CVarGetInt("framerate") * 8);
  207.       ResPropSetInt(Player,"nav_order_alaska",1);
  208.       ResPropSetInt(Player,"nav_order_alaska_time",time_pickup); 
  209.     
  210.       ResPropSetInt(GuiParent(SELF),"Hidden",TRUE);
  211.       stop;
  212.     }
  213.   }    
  214.  
  215.  
  216.   @load_tab_can_load_message {
  217.     resid Player;
  218.     resid Game;
  219.     resid city_data_id;
  220.     resid CurCommodity;
  221.     resid BonusCommodity;
  222.     resid Scenario;
  223.     resid CommodityToLoad;
  224.     str oil_message;
  225.     str pineapple_message;
  226.     str cur_city;
  227.     int num_commodity;
  228.     int i;
  229.     int city_row;
  230.     int oil_flag;
  231.     int pineapple_flag;
  232.     str city_comod_1;
  233.     str city_comod_2;
  234.     str city_comod_3;
  235.     str commodity_found; /* the found commodity */
  236.     str cur_commodity_name;
  237.     str bonus_commodity_name;
  238.     int tmp_int;
  239.     int time_now;
  240.     str nav_cur_city;
  241.   
  242.     Game = ResByName("Game");
  243.     city_data_id  = ResPropGetResID(ResByName("CSVData"), "city_id");
  244.     Player = ResPropGetResID(ResByName("Game"),"game_cur_player");
  245.     Scenario = ResPropGetResID(Player, "scenario_id");
  246.     time_now = ResPropGetInt(Player,"time_now"); 
  247.   
  248.     ResPropAlias(Player, "nav_cur_city","nav_cur_city");
  249.     cur_city = ResPropGetStr(Player,"nav_cur_city");
  250.     num_commodity = ResPropGetInt(Scenario,"scenario_commodity_number_of");
  251.     city_row = CSVSearch(city_data_id,"name",cur_city);
  252.     city_comod_1 = CSVGetStr(city_data_id,"com1",city_row);
  253.     city_comod_2 = CSVGetStr(city_data_id,"com2",city_row);
  254.     city_comod_3 = CSVGetStr(city_data_id,"com3",city_row);
  255.     oil_flag = 0;
  256.     pineapple_flag = 0;
  257.     
  258.     /* '0' being the bonus */
  259.     i = 0;
  260.     
  261.     /* loop through the number of commodities we are playing with */
  262.     while(i <= num_commodity ) {
  263.     
  264.  
  265.  
  266.       
  267.       if (i == 0) {
  268.         CurCommodity = ResPropGetResID(Player,"commodity_bonus");
  269.         cur_commodity_name = ResPropGetStr(CurCommodity,"commodity_name");
  270.       } else {
  271.         CurCommodity = ResPropGetResID(Player,StrFormatStr("commodity_%d",i));
  272.         cur_commodity_name = ResPropGetStr(CurCommodity,"commodity_name");
  273.       }
  274.       
  275.       
  276.  
  277.       if ((city_comod_3 != "") && StrExact(cur_commodity_name,city_comod_3)) {
  278.         if (ResPropGetInt(CurCommodity,"commodity_state") == 0) {
  279.           commodity_found = cur_commodity_name;
  280.           CommodityToLoad = CurCommodity;
  281.           i = 100;
  282.         }
  283.       }
  284.       if ((city_comod_2 != "") && StrExact(cur_commodity_name,city_comod_2)) {
  285.         if (ResPropGetInt(CurCommodity,"commodity_state") == 0) {
  286.           commodity_found = cur_commodity_name;
  287.           CommodityToLoad = CurCommodity;
  288.           i = 100;
  289.         }
  290.       }
  291.       if ((city_comod_1 != "") && StrExact(cur_commodity_name,city_comod_1)) {
  292.         if (ResPropGetInt(CurCommodity,"commodity_state") == 0) {
  293.           commodity_found = cur_commodity_name;
  294.           CommodityToLoad = CurCommodity;
  295.           i = 100;
  296.         }
  297.       }
  298.       
  299.   
  300.   
  301.       /* check if the player is in sf and needs pineapples */
  302.       if ( StrExact(ResPropGetStr(Player,"nav_cur_city"),"San Francisco") && 
  303.            StrExact(ResPropGetStr(CurCommodity,"commodity_name"),"Pineapples")) {
  304.            
  305.         /* check if the order has been made */
  306.         if ( ResPropGetInt(Player,"nav_order_hawaii") == 1) {
  307.           /* check that it has not already been loaded */
  308.           if (ResPropGetInt(CurCommodity,"commodity_state") == 0) {
  309.             /* check if its here yet */
  310.             if ( ResPropGetInt(Player,"time_now") < ResPropGetInt(Player,"nav_order_hawaii_time") ) {
  311.               pineapple_flag = 1; /* not arrived */
  312.             } else {
  313.               pineapple_flag = 2; /* arrived */
  314.               commodity_found = cur_commodity_name;                        
  315.               CommodityToLoad = CurCommodity;
  316.               i = 100;
  317.             }
  318.           }                                       
  319.         }                 
  320.       }
  321.       
  322.       /* check if the player is in sw and needs oil */
  323.       if ( StrExact(ResPropGetStr(Player,"nav_cur_city"),"Seattle") &&     
  324.            StrExact(ResPropGetStr(CurCommodity,"commodity_name"),"Oil")) {
  325.   
  326.   
  327.         /* check if the order has been made */
  328.         if ( ResPropGetInt(Player,"nav_order_alaska") == 1) {
  329.           /* check that it has not already been loaded */
  330.           if (ResPropGetInt(CurCommodity,"commodity_state") == 0) {
  331.             /* check if its here yet */
  332.             if ( ResPropGetInt(Player,"time_now") < ResPropGetInt(Player,"nav_order_alaska_time") ) {
  333.               oil_flag = 1; /* not arrived */
  334.             } else {
  335.               oil_flag = 2; /* arrived */
  336.               commodity_found = cur_commodity_name;                        
  337.               CommodityToLoad = CurCommodity;
  338.               i = 100;
  339.             }
  340.           } 
  341.         }
  342.          
  343.   
  344.            
  345.       }
  346.   
  347.       i += 1;
  348.     }
  349.     
  350.     /* light up the load tab */
  351.     if (! StrExact(commodity_found,"")) {
  352.       if (ResPropGetResID(ResByName("load.tab/tab"),"AnimationID") != ResByName("gui/dash/tab/load/load_on.pcx")) {
  353.         ResPropSetResID(ResByName("load.tab/tab"),"AnimationID",ResByName("gui/dash/tab/load/load_on.pcx"));
  354.       }                
  355.     }
  356.   
  357.     if ( StrExact(city_comod_1,"") && (pineapple_flag == 0) && (oil_flag == 0)) {
  358.         /* no commodities in this city */
  359.         ResPropSetStr(ResByName("load.tab/can_load_layer/can_load_message_label"),"InputText",MangleSIDToStr(65569/*"No needed commodities."*/));
  360.         ResPropSetStr(ResByName("load.tab/can_load_layer/can_load_message"),"InputText",StrFormatStr(MangleSIDToStr(65570/*"Take a look at the country map in the laptop to find out which cities have the commodities you need. "*/), city_comod_1 ,city_comod_2 ,city_comod_3));
  361.     } else {
  362.       if (StrExact(commodity_found,"")) {
  363.         /* has commodities but none you need */
  364.   
  365.   
  366.         /*  see if the order from hawaii is in */
  367.         if (
  368.              (StrExact(nav_cur_city,"San Francisco")) &&
  369.              (ResPropGetInt(Player, "nav_order_hawaii") == 1) &&
  370.              ( 
  371.                (time_now + ResPropGetInt(Player,"time_zone_real_offset")) < 
  372.                ResPropGetInt( Player, "nav_order_hawaii_time") 
  373.              )              
  374.            ) {
  375.           
  376.           tmp_int = ResPropGetInt( Player, "nav_order_hawaii_time") - time_now;
  377.           tmp_int  /= 3600;
  378.            
  379.           pineapple_message = StrFormatStr(MangleSIDToStr(65571/*"   Pineapples ( %d hours ).\n"*/),tmp_int+1);
  380.   
  381.         } else {
  382.   
  383.           /* see if we are in the city at least */
  384.           if ( StrExact(nav_cur_city,"San Francisco") ) {
  385.             pineapple_message = MangleSIDToStr(65572/*"   Pineapples ( from Hawaii ).\n"*/);
  386.           }
  387.         }
  388.   
  389.         
  390.         /*  see if the order from alaska is in */
  391.         if (
  392.              (StrExact(nav_cur_city,"Seattle")) &&
  393.              (ResPropGetInt(Player, "nav_order_alaska") == 1) &&
  394.              ( 
  395.                (time_now + ResPropGetInt(Player,"time_zone_real_offset")) < 
  396.                ResPropGetInt( Player, "nav_order_alaska_time") 
  397.              )              
  398.            ) {
  399.   
  400.           tmp_int = ResPropGetInt( Player, "nav_order_alaska_time") - time_now;
  401.           tmp_int /= 3600;
  402.   
  403.           oil_message = StrFormatStr(MangleSIDToStr(65573/*"   Oil ( %d hours ).\n"*/),tmp_int +1);
  404.         } else {
  405.           /* see if we are in the city at least */
  406.           if ( StrExact(nav_cur_city,"Seattle") ) {
  407.             oil_message = MangleSIDToStr(65574/*"   Oil ( from Alaska ).\n"*/);
  408.           }
  409.         }
  410.   
  411.   
  412.         ResPropSetStr(ResByName("load.tab/can_load_layer/can_load_message_label"),"InputText",MangleSIDToStr(65575/*"No needed commodities."*/));
  413.         ResPropSetStr(ResByName("load.tab/can_load_layer/can_load_message"),"InputText",StrFormatStr(MangleSIDToStr(65576/*"%s produces:\n%s%s   %s\n   %s\n   %s\n\nTake a look at the country map in the laptop to find out which cities have the commodities you need. "*/),cur_city,"","",city_comod_1 ,city_comod_2 ,city_comod_3));
  414.       } else {
  415.         
  416.         if ( ResPropGetInt(Player, "time_business_open") == 1 ) {
  417.   
  418.           if ( pineapple_flag == 1 /* not arrived */) {
  419.             ResPropSetStr(ResByName("load.tab/can_load_layer/can_load_message_label"),"InputText",MangleSIDToStr(65577/*"Your pineapples are not here yet!"*/));
  420.             ResPropSetStr(ResByName("load.tab/can_load_layer/can_load_message"),"InputText",MangleSIDToStr(65578/*"Your pineapples have not arrived yet."*/));
  421.             stop;
  422.           }
  423.   
  424.           if ( pineapple_flag == 2 /* arrived */) {
  425.             ResPropSetStr(ResByName("load.tab/can_load_layer/can_load_message_label"),"InputText",MangleSIDToStr(65579/*"Pineapples ready to load!"*/));
  426.             ResPropSetStr(ResByName("load.tab/can_load_layer/can_load_message"),"InputText",MangleSIDToStr(65580/*"Good work! Your pineapples have arrived. Click the load button to put them in your truck!"*/));
  427.             ResPropSetResID(Player,"nav_commodity_to_load",CommodityToLoad);
  428.             ResPropSetInt(ResByName("load.tab/can_load_layer/load"),"Hidden",FALSE);
  429.             stop;
  430.           }
  431.           
  432.           if ( oil_flag == 1 /* not arrived */ ) {
  433.             ResPropSetStr(ResByName("load.tab/can_load_layer/can_load_message_label"),"InputText",MangleSIDToStr(65581/*"Your oil has not arrived yet."*/));
  434.             ResPropSetStr(ResByName("load.tab/can_load_layer/can_load_message"),"InputText",MangleSIDToStr(65582/*"The oil tanker has not yet arrived. Come back later."*/));
  435.             stop;
  436.           }
  437.   
  438.           if ( oil_flag == 2 /* arrived */ ) {
  439.             ResPropSetStr(ResByName("load.tab/can_load_layer/can_load_message_label"),"InputText",MangleSIDToStr(65583/*"Your oil ready to load!"*/));
  440.             ResPropSetStr(ResByName("load.tab/can_load_layer/can_load_message"),"InputText",MangleSIDToStr(65584/*"Good work! The oil tanker has arrived. Click the load button!"*/));
  441.             ResPropSetResID(Player,"nav_commodity_to_load",CommodityToLoad);
  442.             ResPropSetInt(ResByName("load.tab/can_load_layer/load"),"Hidden",FALSE);
  443.             stop;
  444.           }
  445.   
  446.   
  447.           ResPropSetInt(ResByName("load.tab/can_load_layer/load"),"Hidden",FALSE);
  448.           ResPropSetResID(Player,"nav_commodity_to_load",CommodityToLoad);
  449.           ResPropSetStr(ResByName("load.tab/can_load_layer/can_load_message_label"),"InputText",StrFormatStr(MangleSIDToStr(65585/*"%s ready to load!"*/),commodity_found));
  450.           ResPropSetStr(ResByName("load.tab/can_load_layer/can_load_message"),"InputText",StrFormatStr(MangleSIDToStr(65586/*"Good work! %s produces %s. Click the load button to put this commodity in your truck!"*/),cur_city,commodity_found));
  451.  
  452.           
  453.         } else {
  454.           ResPropSetStr(ResByName("load.tab/can_load_layer/can_load_message_label"),"InputText",StrFormatStr(MangleSIDToStr(65587/*"Business Closed"*/),commodity_found));
  455.           ResPropSetStr(ResByName("load.tab/can_load_layer/can_load_message"),"InputText",StrFormatStr(MangleSIDToStr(65588/*"The company that supplies %s in %s is closed. Hours of operation are 6 am to 10 pm."*/),commodity_found,cur_city));
  456.           ResPropSetInt(ResByName("load.tab/can_load_layer/wait"),"Hidden",FALSE);
  457.         }
  458.       }
  459.     }
  460.   }
  461. }      
  462.       
  463.